﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace oqis.core.dbaccess
{
    /// <summary>
    /// 数据访问对象,加上前缀oqis是为了防止与System.Data下的IDBAccess冲突 
    /// </summary>
    public interface IOQISDBAccess 
    {
        #region 属性

        /// <summary>
        /// 数据适配器
        /// </summary>
        /// <returns></returns>
        IDbDataAdapter DataAdapter { get;  }

        /// <summary>
        /// 执行Sql语句的对象
        /// </summary>
        /// <returns></returns>
        IDbCommand DbCommand { get;  }

        /// <summary>
        /// 数据库连接对象
        /// </summary>
        /// <returns></returns>
        IDbConnection DbConnection { get; }

        /// <summary>
        /// 连接串
        /// </summary>
        string DBConnectionString { get; }

        /// <summary>
        /// 命令字符串
        /// </summary>
        string CommandText { get; set; }

        /// <summary>
        /// 数据库类型
        /// </summary>
        qiaoDBMSType DBMSType { get;  }

        #endregion

        #region 方法

        /// <summary>
        /// 执行sql语句
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <returns></returns>
        int ExcuteNoneQuery(string sql);

        /// <summary>
        /// 查询一条记录
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        object ExcuteScalar(string sql);

        /// <summary>
        /// 获取数据记录表
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        DataTable GetDataTable(string sql);

        /// <summary>
        /// 获取数据集
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        DataSet GetDataSet(string sql);

        /// <summary>
        /// 更新表数据
        /// </summary>
        /// <param name="tableName">待更新的表名</param>
        /// <param name="table">表数据</param>
        /// <returns>返回更新结果</returns>
        bool UpdateTable(string tableName, DataTable table);
 
        #endregion
    }
}
